package com.fp.helig.SceneControler;

import org.anddev.andengine.engine.camera.SmoothCamera;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.extension.physics.box2d.PhysicsConnector;
import org.anddev.andengine.extension.physics.box2d.PhysicsFactory;
import org.anddev.andengine.extension.physics.box2d.PhysicsWorld;

import android.R.bool;
import android.util.Log;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.fp.helig.Res.ObjectParams;

public class StaticObject extends BaseObject {

	public Body mBody;
	
	public StaticObject(float pX, float pY,ObjectParams pParams, PhysicsWorld physicsWorld, SmoothCamera camera, boolean isSensor) {
		// TODO Auto-generated constructor stub 
		super(pX, pY,pParams, physicsWorld,camera);
		 if (isSensor) mParams.mBodyType=SENSOR;
		 createPhysics(camera,physicsWorld);
			//this.animate(55);
		 	//this.setRotation(0.0f);
	}
	
	
	private void createPhysics(final SmoothCamera camera, PhysicsWorld physicsWorld)
	{	
		
		switch (mParams.mBodyType) {
		case BOX_BODY:
			mBody = PhysicsFactory.createBoxBody(physicsWorld, this, BodyType.StaticBody, 
					PhysicsFactory.createFixtureDef(mParams.mDensity,mParams.mElasticity,mParams.mFriction));			
			break;
		case CIRCLE_BODY:
			mBody = PhysicsFactory.createCircleBody(physicsWorld, this, BodyType.StaticBody, 
					PhysicsFactory.createFixtureDef(mParams.mDensity,mParams.mElasticity,mParams.mFriction));
			break;
		case SENSOR:
			FixtureDef areaFixtureDef = PhysicsFactory.createFixtureDef(0, 0, 0);
			areaFixtureDef.isSensor = true;
			mBody = PhysicsFactory.createCircleBody(physicsWorld, this, BodyType.StaticBody, areaFixtureDef);
			break;
		default:
			
			break;
		}
		mBody.setUserData(super.returnThis());

		physicsWorld.registerPhysicsConnector(new PhysicsConnector(this, mBody, true, true));
	}

	
	
}
